
# Makefile for msql languange. 

#@AR: static liba generator
#@ARFLAGS:
#	-cru: 
#@CC: C or C++ complier
#@CFLAGS: 
#	-g: using it to complie,we can debug the executable files using GDB tool
#	-w: printf all the warnings
#      -03: optimise the sources validly
#	-fpic: files generated will do no relative with address.auto to process the GOT ADDRESS
#	-pipe: can use the pipes instead of files
#	-H: printf the include files used
#	-Q: printf all the functions defined
#@liba: the static lib to be generated
#@libs: the active-linked lib to be generated
#@OBJS: all the obj files to be generated
#@exec: the obj-executalbe file to be generated
#@path: directory used for saving the files generated
#$@: the target to be generated
#$^: all depended to the target $@
#$<: first depended to the target $@
#$?: all the new depended to the target $@

PRJ = .
OS = win
#OS = linux
AR = ar
ARFLAGS = -cru
CC = gcc
CFLAGS = -g -w -O3 -fpic -pipe -DCHUNKSIZE=65536
CFLAGS += -I $(PRJ)

OBJS =\
$(PRJ)/tree.o \
$(PRJ)/hsearch.o \
$(PRJ)/parser.o \
$(PRJ)/lex.o \
$(PRJ)/syntax.o	

exec = msql
path = debug/
scripts = scripts

all: $(exec)
$(exec):$(OBJS)
		$(CC) $(CFLAGS) -o $@ $^
		mv $(OBJS) $(path)
		mv $@ $(path)
		chmod 777 *
		chmod 777 */*
		
$(OBJS):%.o:%.c
		$(CC) -c $(CFLAGS) $^ -o $@

.PHONY: clean
clean:
		clsb
		rm -rf $(PRJ)/*.o $(PRJ)/*.exe $(PRJ)/$(path)*.* 
db:
		clsb
		$(path)$(exec)
tar:
		clsb
		$(scripts)/disttar.sh

